<?php
include_once("d:/collect_new/collect/Lib/ORG/Zqnews.class.php");
include_once("d:/collect_new/collect/Common/common.php");
if (!function_exists("createdir")) {
    function createdir($filepath)
    {
        $nn = preg_split("/(?<!\:)\//", $filepath);
        $temppath = "";
        for ($i = 0; $i < count($nn); $i++) {
            $temppath .= (($i > 0) ? "/" : "") . $nn[$i];
            if (!is_dir($temppath)) {
                @mkdir($temppath, 0777);
            }
        }
    }
}


if (!function_exists("u")) {
    function u($text)
    {
        $new = array();
        if (is_array($text)) {
            foreach ($text as $k => $v) {
                $new[u($k)] = u($v);
            }
            $text = $new;
        }
        if (is_object($text)) {
            $text = array2object(u(object2array($text)));
        }
        if (is_string($text)) {
            $text = iconv("GB2312", "utf-8//IGNORE", $text);
        }
        return $text;
    }
}

if (!function_exists("g")) {
    function g($text)
    {
        if (is_array($text)) {
            $new = array();
            foreach ($text as $k => $v) {
                $new[g($k)] = g($v);
            }
            $text = $new;
        }
        if (is_object($text)) {
            $text = array2object(g(object2array($text)));
        }
        if (is_string($text)) {
            $text = iconv("UTF-8", "GB2312//IGNORE", $text);
        }
        return $text;
    }
}

function object2array(&$object)
{
    $object = json_decode(json_encode($object), true);
    return $object;
}

function array2object($arrGiven)
{
    $objResult = new stdClass();
    foreach ($arrGiven as $key => $value) {
        if (is_array($value)) $value = array2object($value);
        $objResult->{$key} = $value;
    }
    return $objResult;
}

if (function_exists('isutf8')) {
    function isutf8($string)
    {
        $str_len = strlen($string);
        for ($i = 0; $i < $str_len;) {
            $str = ord($string[$i]);
            if ($str >= 0 && $str < 0x7f) {
                $i++;
                continue;
            }
            if ($str < 0xc0 || $str > 0xfd) return false;
            $count = $str > 0xFC ? 5 : $str > 0xf8 ? 4 : $str > 0xf0 ? 3 : $str > 0xe0 ? 2 : 1;
            if ($i + $count > $str_len) return false;
            $i++;
            for ($m = 0; $m < $count; $m++) {
                if (ord($string[$i]) < 0x80 || ord($string[$i]) > 0xbf) return false;
                $i++;
            }
        }
        return true;
    }
}

if (function_exists('getIP')) {
    function getIP()
    {
        if (!empty ($_SERVER ["HTTP_CLIENT_IP"])) {
            $cip = $_SERVER ["HTTP_CLIENT_IP"];
        } else if (!empty ($_SERVER ["HTTP_X_FORWARDED_FOR"])) {
            $cip = $_SERVER ["HTTP_X_FORWARDED_FOR"];
        } else if (!empty ($_SERVER ["REMOTE_ADDR"])) {
            $cip = $_SERVER ["REMOTE_ADDR"];
        } else {
            $cip = '';
        }
        preg_match("/[\d\.]{7,15}/", $cip, $cips);
        $cip = isset ($cips [0]) ? $cips [0] : 'unknown';
        unset ($cips);
        return $cip;
    }
}

function strip_jscss($str, $lie_a = false)
{
    preg_match_all("/<script\b[^<>]*>.*<\/\s*script\s*\/?>/Uisx", $str, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        if (preg_match("/reload|AC_FL_RunContent/Uisx", $nn[0][$i])) {
            if (preg_match("/http\:\/\/([^<>]*.swf)/Uisx", $nn[0][$i], $mm)) {
                $str = str_replace($nn[0][$i], "[media=swf,500,375]{$mm[0]}[/media]", $str);
                continue;
            }
        }
        $str = str_replace($nn[0][$i], "", $str);
    }
    $str = preg_replace("/<SCRIPT\b[^<>]*>.*(<\/\s*script\s*\/?>|$)/Uisx", "", $str);
    $str = preg_replace("/<select\b[^<>]*>.*(<\/\s*select\s*\/?>|$)/Uisx", "", $str);
    $str = preg_replace("/<\/?br\s*\/?>|&lt;\/br\s*\/?&gt;/Uisx", "\r\n", $str);
    $str = preg_replace("/<style\b[^<>]*>.*<\/\s*style\s*\/?>/Uisx", "", $str);
    $str = preg_replace("/<img[^<>]*src=\"[^<>]*\"[^<>]*file=\"([^<>]*)\"[^<>]*>/Uisx", "<img src=\"\\1\">", $str);
    if (!$lie_a) $str = preg_replace("/<\/?a(?=\>|\s)[^<>]*>/Uisx", "", $str);
    $str = preg_replace("/(?<![=\"\'\]\[])(http\:\/\/[^<>]*\.(jpg|gif|png))/Uisx", "<img src=\"\\1\">", $str);
    $str = preg_replace("/([0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}|(半|[0-9])(小时|天)前)[^<>]*下载附件[^<>]*KB\)/", "", $str);
    return $str;
}

function my_array_max($arr)
{
    if (!empty($arr)) {
        foreach ($arr as $key => $value) {
            if (!isset($max) || ($max < $value)) {
                $max = $value;
                $max_key = $key;
            }
        }
    } else {
        return 0;
    }
    return $max_key;
}

function unicode_encode1($name)
{
    $name = iconv('GB2312', 'UCS-2', $name);
    $len = strlen($name);
    $str = '';
    for ($i = 0; $i < $len - 1; $i = $i + 2) {
        $c = $name[$i];
        $c2 = $name[$i + 1];
        if (ord($c) > 0) {
            $str .= '\u' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
        } else {
            $str .= $c2;
        }
    }
    return $str;
}

function cn2utf8($str)
{
    if (!is_utf8($str)) {
        $str = iconv("GB2312", "UTF-8//IGNORE", $str);

    }
    return $str;
}


function utf82cn($name)
{
    $tostr = "";
    if (is_utf8($name)) {
        for ($i = 0; $i < strlen($name); $i++) {
            $curbin = ord(substr($name, $i, 1));
            if ($curbin < 0x80) {
                $tostr .= substr($name, $i, 1);
            } elseif ($curbin < bindec("11000000")) {
                $str = substr($name, $i, 1);
                $tostr .= "&#" . ord($str) . ";";
            } elseif ($curbin < bindec("11100000")) {
                $str = substr($name, $i, 2);
                $tostr .= "&#" . GetUnicodeChar($str) . ";";
                $i += 1;
            } elseif ($curbin < bindec("11110000")) {
                $str = substr($name, $i, 3);
                $gstr = iconv("UTF-8", "GB2312//IGNORE", $str);
                //$gstr= iconv("UTF-8","GBK",$str);
                if (!$gstr) {
                    $tostr .= "&#" . GetUnicodeChar($str) . ";";
                } else {
                    $tostr .= $gstr;
                }

                $i += 2;
            } elseif ($curbin < bindec("11111000")) {
                $str = substr($name, $i, 4);
                $tostr .= "&#" . GetUnicodeChar($str) . ";";

                $i += 3;
            } elseif ($curbin < bindec("11111100")) {
                $str = substr($name, $i, 5);
                $tostr .= "&#" . GetUnicodeChar($str) . ";";

                $i += 4;
            } else {
                $str = substr($name, $i, 6);
                $tostr .= "&#" . GetUnicodeChar($str) . ";";

                $i += 5;
            }
        }
        return $tostr;
    } else {
        return $name;
    }
}

function GetUnicodeChar($str)
{
    $temp = "";
    for ($i = 0; $i < strlen($str); $i++) {
        $x = decbin(ord(substr($str, $i, 1)));
        if ($i == 0) {
            $s = strlen($str) + 1;
            $temp .= substr($x, $s, 8 - $s);
        } else {
            $temp .= substr($x, 2, 6);
        }
    }
    return bindec($temp);
}

function is_utf8($str)
{
    if (preg_match("/\\\u[0-9a-z]{4}/i", $str)) {
        return true;
    }
    $c = 0;
    $b = 0;
    $bits = 0;
    $len = strlen($str);
    for ($i = 0; $i < $len; $i++) {
        $c = ord($str[$i]);
        if ($c > 128) {
            if (($c >= 254)) return false;
            elseif ($c >= 252) $bits = 6;
            elseif ($c >= 248) $bits = 5;
            elseif ($c >= 240) $bits = 4;
            elseif ($c >= 224) $bits = 3;
            elseif ($c >= 192) $bits = 2;
            else return false;
            if (($i + $bits) > $len) return false;
            while ($bits > 1) {
                $i++;
                $b = ord($str[$i]);
                if ($b < 128 || $b > 191) return false;
                $bits--;
            }
        }
    }
    return true;
}


function dquanurl($nr, $wurl)
{
    if (preg_match_all("/<base\s+href=\"([^<>]*)\"/Uisx", $nr, $nn)) {
        $baseurl = trim($nn[1][0]);
    }

    $nr = preg_replace("/(src|location|<link[^>]*href|<EMBED[^>]*VALUE|action|background|imgurl|<PARAM\s+NAME\=movie\s+VALUE|href)\s*=\s*(\"|\')?([^\"\'\>\s]+)(\\2|(?=\>)|\s)/Uisxe", "'\\1=\"'.quanurl('\\3','$wurl','$baseurl').'\"'", $nr);

    $nr = preg_replace("/url\((\"|'|)?([^<>\s\"']+)\\1\)/Uisxe", '"url(".quanurl("\\2",$wurl).")"', $nr);
    $nr = stripCSlashes($nr);
    return $nr;
}

function quanurl($subUrl, $wurl, $baseurl = "")
{
    $subUrl=str_replace("\\","/",$subUrl);
    if (is_array($subUrl)) return;
    $hh=parse_url($wurl);
    if(preg_match("/^\/\//",$subUrl)){
        $subUrl=$hh['scheme'].":".$subUrl;
    }
    if(preg_match("/^blob\:/",$subUrl)){
        return $subUrl;
    }
    $wurl=urldecodeUrl($wurl);
    $baseurl=urldecodeUrl($baseurl);
    if(is_string($subUrl)) $subUrl=urldecode($subUrl);
    if (is_array($subUrl) || $subUrl == "") return "";
    preg_match("/(https?)\:\/\//Uisx",$wurl,$nn);
    $https=($nn[1]==null)?"http":$nn[1];
    $baseurl = preg_replace("/(https?\:\/\/[^\/]+)$/Uisx", "\\1/", $baseurl);
    if(!preg_match("/(https?\:\/\/[^\/]+)$/Uisx",$baseurl)){
        $baseurl="";
    }
    $subUrl = str_replace('\\', "/", trim($subUrl));
    $subUrl = str_replace('&amp;', "&", $subUrl);
    $subUrl = preg_replace("/^\.\?/", "?", $subUrl);
    $wurl = ($baseurl) ? $baseurl : $wurl;
    $wurl = preg_replace("/\?.*$/Uisx", "", $wurl);
    preg_match_all("/(https?\:\/\/([^\/]*?))(.*)$/Uimx", $wurl, $mm);
    $host = $mm[2][0];
    $subUrl=preg_replace("/^\/\//",$https."://",$subUrl);
    if (substr($subUrl, 0, 7) == "http://"||substr($subUrl, 0, 8) == "https://") {
        $newurl = $subUrl;
    } elseif (preg_match("/^\//", $subUrl)) {
        $newurl = "{$https}://" . $host . $subUrl;
    } elseif (preg_match("/^\.\.\//", $subUrl)) {
        $tmsuburl = $subUrl;
        $tempparentUrl = $wurl;
        preg_match_all("/(\.\.\/)/Uisx", $subUrl, $nn);
        for ($i = 0; $i < count($nn[1]); $i++) {
            $tmsuburl = preg_replace("/^\.\.\//", "", $tmsuburl);
            if(!preg_match("/https?\:\/\/[^<>\/]+\/?$/Uisx",$tempparentUrl)) {
                $tempparentUrl = preg_replace("/(?!<\/)\/[^<>\/]*\/[^<>\/]*$/", "/", $tempparentUrl);
            }
        }
        $newurl = preg_replace("/\/$/", "", $tempparentUrl) . "/" . $tmsuburl;
    } elseif (preg_match("/^[^\.\/\?]/", $subUrl)) {
        preg_match("/^(.*)\//Uisx", $subUrl, $nna);
        preg_match("/https?\:\/\/.*\/(.*)\//Uisx", $wurl, $nnb);
        if ($nnb[1] == $nna[1]&&$nnb[1]!=null) {
            $newurl = $https."://" . $host . "/" . $subUrl;
        } elseif(!preg_match("/^http/i",$subUrl)) {
            $newurl = dirname2($wurl) . "/" . $subUrl;
        }elseif(preg_match("/^http/i",$subUrl)){
            $newurl = $subUrl;
        }
    } elseif (preg_match("/^\?/", $subUrl)) {
        $newurl = preg_replace("/\?.*$/U", "", $wurl) . $subUrl;
    } else {
        $newurl = preg_replace("/\/[^\/]*$/", "/", $wurl) . $subUrl;
    }
    $newurl = preg_replace("/\/\.\//", "/", $newurl);
    $newurl = preg_replace("/\/https?\:\//", "/", $newurl);
    $newurl = preg_replace("/[\r\n]/", "", $newurl);
    $newurl = preg_replace("/(https?\:)\/{1,}/", "\\1//", $newurl);
    return $newurl;
}

function host($str)
{
    $str=urldecode($str);
    preg_match_all("/https?\:\/\/(?:[^<>\/]*?)([a-z0-9_]+?\.(?:com|gov|edu|org|mobi|la|us|hk|tw|net|cn|vn|cc|info|top|vip|site)(?:(?:\.net|\.cn|\.cc|\.tv|\.hk|\.tw|\.info|\.vn|\.top|\.vip)*(?=\:|\/|$)))/isx", $str, $nn);
    $host = $nn[1][0];
    $host = preg_replace("/^(?:[^<>]*\.)*([a-z0-9_]+\.(com|gov|edu|org|cn|mobi|la|hk|tw|us|cc|info|vn|top|vip|site))/Uisx", "\\1", $host);
    if($host==""&&preg_match("/https?\:\/\/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/",$str,$nn)){
        $host=$nn[1];
    }
    return $host;
}



function clmh($str)
{
    $str = preg_replace("/(\r|\n)+$/Uisx", "", trim($str));
    $str = preg_replace("/(\r|\n)+/m", "\\r\\n", trim($str));
    $str = preg_replace("/\"/m", "\\\"", trim($str));
    $str = preg_replace("/\&amp\;/m", "&", trim($str));
    return $str;
}

function droppagetablediv($nr, $nextpagere = "", $bug = 0)
{
    if (!is_utf8($nextpagere)) $nextpagere = u($nextpagere);
    $re = ".*(?<![^\<\>a-z0-9_\s])(下一页|下页|上一页|上页" . $nextpagere . ").*";
    $nr = preg_replace("/<p[^<>]*>{$re}(<\/p>|(?:<\/(td|div)))/Uisx", "", $nr);
    $nr = preg_replace("/(<br>|<p[^<>]*>|\s)*<table[^<>]*>{$re}<\/table>/Uisx", "", $nr);
    $nr = preg_replace("/(<br>|<p[^<>]*>|\s)*&lt;table[^<>]*&gt;{$re}&lt;\/table&gt;/Uisx", "", $nr);
    $nr = preg_replace("/(<br>|<p[^<>]*>|\s)*<div[^<>]*>{$re}<\/div>/Uisx", "", $nr);
    $nr = preg_replace("/(<br>|<p[^<>]*>|\s)*&lt;div[^<>]*&gt;{$re}&lt;\/div&gt;/Uisx", "", $nr);
    $nr = preg_replace("/(\[?上一页|下一页|\[[0-9]+\](?:\[|\s\<)).*$/Uisx", "", $nr);
    $nr = preg_replace("/前一页|首页/Uisx", "", $nr);
    return $nr;
}


function mustzw($str)
{
    preg_match_all("/([\x{4e00}-\x{9fa5}A-Za-z0-9_]+)/uisx", $str, $nn);
    return $nn[1][0];
}


//通杀
function tongx($str, $nr, $isint = 0)
{


    $mm = preg_split("/,|\;/", $str);
    $arr = array();

    foreach ($mm as $one) {
        //for($i=0;$i<count($mm);$i++){
        if (trim($one) == "") continue;
        $isints = ($isint) ? "0-9\," : "^<>";
        switch ($isint) {
            case 1:
                $isints = "0-9\,";
                $u = "";
                break;
            case 2:
                $isints = "\x{4e00}-\x{9fa5}A-Za-z0-9_\'\\\"";
                $u = "u";
                break;
            default:
                $isints = "^<>";
                $u = "";
        }

        $re = "/" . chakai($one) . "(?:\:|：|：| | |<\/?(?:strong|b|a|font|td|span|th|em|li|span)[^<>]*>|\&nbsp\;|\s|　)+?([" . $isints . "]+?)/Uisx{$u}";
        if (preg_match_all($re, $nr, $nn)) {
            foreach ($nn[1] as $onn) {
                if (trim($onn) != "") {
                    $arr[] = clwz($onn);
                }
            }
        }


        $re = "/(?:<\/?(?:strong|b|a|font|td|span|th|em|li)[^<>]*>|\&nbsp\;|\s|　)([0-9\,]+?)(?:<\/?(?:strong|b|a|font|td|span|th|em|li)[^<>]*>|\&nbsp\;|\s)*" . chakai($one, 1) . "(?![\x{4e00}-\x{9fa5}A-Za-z0-9_]|\)|\,|，|。)/Uuisx";
        //echo $re."\r\n";

        if (preg_match_all($re, $nr, $nn)) {
            foreach ($nn[1] as $onn) {
                if (trim($onn) != "") {
                    $arr[] = clwz($onn);
                }
            }
        }


        $re = "/<META\s+name=\\\"" . chakai($one) . "\\\"\s+content=\\\"([^<>]*)\\\">/Uisx";
        if (preg_match_all($re, $nr, $nn)) {
            foreach ($nn[1] as $onn) {
                if (trim($onn) != "") {
                    $arr[] = clwz($onn);
                }
            }
        }
    }


    $return = "";
    foreach ($arr as $oarr) {
        if (strlen($oarr) > strlen($return)) {
            $return = $oarr;
        }
    }
    return $return;
}

function chakai($str, $nowei = 0)
{
    //$str=addsla($str);
    if (!isutf8($str)) {
        $str = preg_replace("/([" . chr(0xb0) . "-" . chr(0xf7) . "][" . chr(0xa1) . "-" . chr(0xfe) . "])/", "\\1(?:\s| |\&nbsp\;|<(?:span|b|strong)[^<>]*>(?:<\/?(?:span|b|strong)>)?)*", $str);//GBK
    } else {
        $str = preg_replace("/([\x{4e00}-\x{9fa5}])/u", "\\1(?:\s| |\&nbsp\;|<(?:span|b|strong)[^<>]*>(?:<\/?(?:span|b|strong)>)?)*", $str);//utf8
    }
    if ($nowei) {
        $str = substr($str, 0, strlen("(?:\s| |\&nbsp\;|<(?:span|b|strong)[^<>]*>(?:<\/?(?:span|b|strong)>)?)*") * (-1));
    }
    preg_match("/ substr($str, 0, s/Uisx",$nn);
    return $str;
}


function addsla($yy)
{
    $restr = str_replace("\\", "\\\\\\", $yy);
    $restr = str_replace(".*", "allall", $yy);
    $restr = str_replace(".", "\.", $restr);
    $restr = preg_replace("/\\\$/Uisx", "\\\\\\\\\\\\$", $restr);
    $restr = preg_replace("/\"/Uisx", "\\\"", $restr);
    $restr = preg_replace("/\-/Uisx", "\\-", $restr);
    $restr = preg_replace("/\:/Uisx", "\\:", $restr);
    $restr = preg_replace("/\?/Uisx", "\\?", $restr);
    $restr = preg_replace("/\//Uisx", "\\/", $restr);
    $restr = preg_replace("/\{/Uisx", "\\{", $restr);
    $restr = preg_replace("/\}/Uisx", "\\}", $restr);
    $restr = preg_replace("/\(/Uisx", "\\(", $restr);
    $restr = preg_replace("/\)/Uisx", "\\)", $restr);
    $restr = preg_replace("/\|/Uisx", "\\|", $restr);
    $restr = preg_replace("/\,/Uisx", "\\,", $restr);
    $restr = preg_replace("/\!/Uisx", "\\!", $restr);
    $restr = preg_replace("/\^/Uisx", "\\^", $restr);
    $restr = preg_replace("/\*/Uisx", ".*", $restr);
    $restr = preg_replace("/\#/Uisx", "\\#", $restr);
    $restr = preg_replace("/\]/Uisx", "\\]", $restr);
    $restr = preg_replace("/\[/Uisx", "\\[", $restr);
    $restr = preg_replace("/\+/Uisx", "\\+", $restr);
    $restr = preg_replace("/((\\s\+)?(\\n)?\\s)+/m", "\\\s+", $restr);
    $restr = preg_replace("/MMM$/Uisx", "", $restr);
    $restr = preg_replace("/\\\\s\+MMM\\\\s\+/", "[\s\\n]+", $restr);
    $restr = str_replace("allall", ".*", $restr);
    return $restr;
}

function clwz($str)
{
    $str = preg_replace("/\'(.*)\'.*$/Uisx", "\\1", $str);
    $str = preg_replace("/'|\"|\\\\\"|null/Uisx", "", $str);
    $str = preg_replace("/([0-9]+)[\x{4e00}-\x{9fa5}<]*$/Uuisx", "\\1", $str);
    return $str;
}


function cltitle($str)
{
    $str = preg_replace("/\\\'/Uisx", "'", $str);
    $str = preg_replace("/\\\\\"/Uisx", '"', $str);
    return $str;
}

function htmltotxt($str, $n = 0, $thisurl = "")
{
    global $rs;
    $str = trim($str);
    $str = preg_replace("/\"/", "\\\"", strip_tags2($str, "p|img|br|td|table|tr|ul|li|span"));
    preg_match_all("/<img(.*)(?<!width|height|\=|\.)>/Uisx", $str, $nn00);
    for ($i = 0; $i < count($nn00[1]); $i++) {
        preg_match_all("/file\s*\=\s*\\\?\"([^<>]*)\\\??\"/Uisx", $nn00[0][$i], $nnn3);
        $src = trim($nnn3[1][0]);
        if ($src == "") {
            preg_match_all("/original\s*\=\s*\\\?\"([^<>]*)\\\??\"/Uisx", $nn00[0][$i], $nnn2);
            $src = trim($nnn2[1][0]);
        }
        if ($src == "") {
            preg_match_all("/(?:real_src|data-lazyload-src|data-original|src[0-9]+)\s*\=\s*\\\?\"([^<>]*)\\\??\"/Uisx", $nn00[0][$i], $nnn2);
            $src = trim($nnn2[1][0]);
        }
        if ($src == "") {
            preg_match_all("/src[0-9]*\s*\=\s*\\\?\"([^<>]*)\\\??\"/Uisx", $nn00[0][$i], $nnn2);
            $src = trim($nnn2[1][0]);
        }
        if ($rs['loadimg'] == 1) {
            //echo $str."\r\n";
            $str = str_replace($nn00[0][$i], "\r\n[align=center][img]http://collect.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url=" . surlencode(quanurl(trim($src), $thisurl)) . "[/img][/align]<p>\r\n", $str);
        } else {
            $str = str_replace($nn00[0][$i], "\r\n&nbsp;\r\n[align=center][img]" . quanurl(trim($src), $thisurl) . "[/img][/align]<p>\r\n&nbsp;\r\n", $str);
        }
    }

    $str = preg_replace("/\&ldquo\;/Uisx", "\"", $str);
    $str = preg_replace("/\&rdquo\;/Uisx", "\"", $str);
    $str = preg_replace("/<(\/?)\s*(br|p)[^<>]*>/isx", "\r\n", $str);
    $str = preg_replace("/(\r\s*\n)+/m", "\r\n", $str);
    $str = preg_replace("/<(\/?)(td|table|tr|li|ul)\b([^<>]*)>/Uisx", "", $str);
    $str = preg_replace("/\[img\][^<>\[\]]*Array\[\/img\]/Usx", "", $str);
    //$str=preg_replace("/(\n\s*\r)+/s","\r\n[align=center][/align]　　",trim($str));
    //$str=preg_replace("/(\[align=center\]\s*\[\/align\](\s|　)*){2,}/isx","\r\n",$str);
    //$str=preg_replace("/$/m","\r\n[align=center][/align]",$str);
    //$str=preg_replace("/(\r\s*\n)+/m","",$str);
    //$str=preg_replace("/^([\x{4e00}-\x{9fa5}a-zA-Z\s0-9\&\;]+)$/Uuimx","<p>[align=left]\\1[/align]\r\n",$str);
    //$str=preg_replace("/(?<=。|”|？|^)(\n|\r)/","",$str);
    //$str=preg_replace("/\[align=center\]\s*\[\/align\]$\s*/im","\r\n[align=center][/align]　　",$str);
    //$str=preg_replace("/(\r\s*\n)+/m","",$str);
    $str = preg_replace("/^(　　)?/m", "\r\n[align=center][/align]　　", $str);
    $str = preg_replace("/^\s*\[align=center\]\[\/align\]　　\s*(http\:\/\/[^<>]*\.jpg)\s*$/Uixm", "\r\n[align=center][/align]　　[align=center][img]\\1[/img][/align]", $str);
    $str = preg_replace("/(\r\s*\n)+/m", "\r\n", $str);
    $str = preg_replace("/(。|；|？)(?!\r|\n)　　/", "\\1\n[align=center][/align]　　", $str);
    $str = preg_replace("/^\s*/", "", $str);
    $str = str_replace('\"', '"', $str);
    return trim($str);
}

function getre($host, $fieldname = "nr", $gather_type = 1)
{
    $t = new t();
    $t->set("127.0.0.1", "root", "159456", "longzs");
    $rs = $t->sqlone("select * from longzs_re where host='" . trim($host) . "'  ORDER BY updatetime DESC");
    return $rs;
}

function qz($re, $nr = "")
{
    preg_match_all("/" . trim($re) . "/Uisx", $nr, $nn);
    return $nn[1][0];
}


function redo($url, &$secexe = 0, $soucere = "", $mbre = "", $starti = 0, $endi = 0, $sameurlre = "\/([^<>\/]*)\/[^<>\/]*$")
{
    global $news2;
    static $leiji, $setin, $oldurl;
    $leiji = ($leiji == "") ? 0 : $leiji;
    $str = "";
    $oldnr = "";
    $url2 = "";
    jsstart();
    preg_match("/$sameurlre/Uisx", $url, $nn);
    if ($setin != $nn[1][0] && $setin != "") return "";
    $setin = $nn[1][0];
    for ($i = $starti; $i <= $endi; $i++) {
        $url2 = $url;
        if ($soucere != "" && $mbre != "") {
            $url2 = preg_replace("/" . $soucere . "/Uisx", preg_replace("/%1/Uisx", $i, $mbre), $url2);
        }
        //echo "\r\n\r\n\r\npage:{$i}------------$url------$soucere------$mbre-------".$url2;
        if ($url2 == $oldurl) {
            break;
        } else {
            if ($news2->bug == 2) echo "\r\n\r\n\r\n--page:{$i}------------$url-------------------" . $url2;
            $oldurl = $url2;
        }
        if ($news2->bug == 2) echo "\r\n" . ceil(js()) . "\r\n";
        if (ceil(js()) > 30 || $leiji > 40) return $str;
        $leiji++;
        $news2 = new Zqnews($url2);
        $secexe = $news2->secexe = 1;
        $str .= "\r\n" . $news2->getnr();
        $news2->nr = (!isutf8($news2->nr)) ? u($news2->nr) : $news2->nr;
        if ($oldnr == $news2->nr) {
            break;
        } else {
            $oldnr = $news2->nr;
        }
    }
    $str = preg_replace("/\[align=center\]\[\/align\]/", "", $str);
    return $str;

}


function strip_tags2($str, $s)
{
    $str = preg_replace("/(desc|alt)=\"(.*)\"/Uisxe", '"\\1=\"".strip_tags3("\\2")."\""', $str);
    $str = preg_replace("/<(?!\/|" . $s . "|script|b).*(?<!width|height|\=|\.)>/Uisx", "", $str);
    $str = preg_replace("/<\/(?!" . $s . "|script|b).*(?<!width|height|\=|\.)>/Uisx", "", $str);
    return $str;

}

function strip_tags3($str)
{
    $str = preg_replace("/\&lt\;.*\&gt\;/Uisx", "", $str);
    return $str;

}


function addsla2($str, $args = array())
{
    $nn = preg_split("/@@/", $str);
    $n = 0;

    do {
        preg_match_all("/.*?(\(\.\*\)|\(\.\+\)|\(\[\^\<\>\]\*\)|\\\\\\/|\(\[[<>\+\\\-_a-z\%\/0-9\^\$]+\]\*\)|\:y\b|\:nn[0-9]+?|\.\*|\(\[0\-9\]\*\)|\(\[0\-9\]\+\)|\[0\-9\]|\{标题\}|\{内容\}|\{变量[0-9]+\}|\\\'|\\\s+|\\\r|\\\n|\+|\*|\\\$|\\\^)/isx", trim($nn[0]), $mm);
        $replace_times = 1;
        $nn[0] = str_replace($mm[1][0], "&&" . $n . "&&", $nn[0], $replace_times);
        $arr[$n] = $mm[1][0];
        $n++;
    } while (count($mm[1]) > 0 && $n < 5);
    $nn[0] = addsla($nn[0]);
    $nn[0] = preg_replace_callback("/&&([0-9]+)&&/Uisx", function ($item) {
        return $item[1];
    }, $nn[0]);
    $nn[0] = addslashes($nn[0]);
    if (count($nn) == 1) {
        return $nn[0];
    } else {
        return $nn[0] . "@@" . $nn[1];
    }
}

function jcre($txt, $args = array())
{
    extract($args);
    if(substr(trim($txt),0,1)=="."||substr(trim($txt),0,1)=="#"||preg_match("/^(div\b|a\b|span\b|p\b|li\b|em\b|h[0-9]+|td\b|tr\b)/Uisx",trim($txt))){
        return $txt;
    }
    preg_match_all("/^(.*)$/Uimx", $txt, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        $dd = preg_split("/@@|\:nn/", $nn[1][$i]);
        $ynn[1][$i] = $dd[0];
        $dd[0] = preg_replace("/(\.|。|" . g("。") . "){3,}/", "(.*)", $dd[0]);
        $dd[0] = preg_replace("/(x|\*){3,}/", ".*", $dd[0]);
        $dd[0] = preg_replace("/(\<|\>){3,}/", "([^<>]*)", $dd[0]);
        $dd[0] = preg_replace("/(?<![0-9])0{3,}/", "([0-9]*)", $dd[0]);
        if (preg_match("/(?<!\\\)\"|\s|(?<!\\\)\//Uis", trim($dd[0]))) {
            $txt = str_replace(trim($ynn[1][$i]), addsla2(trim($dd[0])), $txt);
        }
    }
    $txt = preg_replace("/((?:href|src|value|file)[0-9\s]*)=([\\\\'\"]*)\(\.\*\\\*\)/", "\\1=\\2([^<>\\\\\s]*)", $txt);
    $txt = preg_replace("/\\\\\\\\\"\.\*\\\\\\\\\"/", "\\\\\\\"([^<>]*)\\\\\\\"", $txt);
    $txt = preg_replace("/\\\{5}/", "\\\\\\\\\\", $txt);
    return $txt;
}

function addsla0($str)
{
    $str = str_replace('\\', '\\\\\\\\', $str);
    return $str;
}


function striponexg($str)
{
    $str = str_replace('\\', "&&&&", $str);
    $str = preg_replace("/\\\/", "", $str);
    $str = preg_replace('/&&&&/', "\\", $str);
    return $str;

}

function istextarea($str)
{
    if (preg_match("/\。|，|“|：|\&nbsp\;|<img|\[/Uisx", $str) || strlen($str) > 100) {
        return true;
    }
    return false;
}

function curl_file_get_contents($durl)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $durl);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
    curl_setopt($ch, CURLOPT_REFERER, _REFERER_);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch,  CURLOPT_KEEP_ALIVE, 1);
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}


function curl_file_get_contents2($urlArray)
{
    if (empty($urlArray)) return false;
    $isStr = false;
    if (is_string($urlArray)) {
        $urlArray = array($urlArray);
        $isStr = true;
    }
    $mh = curl_multi_init(); //curl_multi_init --  Returns a new cURL multi handle
    $curlArray = array();
    foreach ($urlArray as $i => $url) {
        $curlArray[$i] = curl_init($url);
        curl_setopt($curlArray[$i], CURLOPT_RETURNTRANSFER, true); //设置为true表示返回抓取的内容，而不是直接输出到浏览器上。TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly
        curl_setopt($curlArray[$i], CURLOPT_AUTOREFERER, true); //自动设置referer。TRUE to automatically set the Referer: field in requests where it follows a Location: redirect.
        curl_setopt($curlArray[$i], CURLOPT_FOLLOWLOCATION, true); //跟踪url的跳转，比如301, 302等
        curl_setopt($curlArray[$i], CURLOPT_MAXREDIRS, 2); //跟踪最大的跳转次数
        curl_setopt($curlArray[$i], CURLOPT_HEADER, 0); //TRUE to include the header in the output.
        curl_setopt($curlArray[$i], CURLOPT_ENCODING, ""); //接受的编码类型,The contents of the "Accept-Encoding: " header. This enables decoding of the response. Supported encodings are "identity", "deflate", and "gzip". If an empty string, "", is set, a header containing all supported encoding types is sent.
        curl_setopt($curlArray[$i], CURLOPT_CONNECTTIMEOUT, 5); //连接超时时间
        curl_multi_add_handle($mh, $curlArray[$i]); //curl_multi_add_handle --  Add a normal cURL handle to a cURL multi handle
    }

    $running = NULL;
    $count = 0;
    do {
        //10秒钟没退出，就超时退出
        if ($count++ > 50) break;
        usleep(50000);
        curl_multi_exec($mh, $running); //curl_multi_exec --  Run the sub-connections of the current cURL handle
    } while ($running > 0);

    $content = array();
    foreach ($urlArray as $i => $url) {
        $content[$url] = curl_multi_getcontent($curlArray[$i]); //curl_multi_getcontent --  Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set
    }

    //curl_multi_remove_handle --  Remove a multi handle from a set of cURL handles
    foreach ($urlArray as $i => $url) {
        curl_multi_remove_handle($mh, $curlArray[$i]);
    }

    //curl_multi_close --  Close a set of cURL handles
    curl_multi_close($mh);
    //如果参数$urlArray是字符串，则将返回值也转换为字符串
    if ($isStr) $content = implode('', $content);
    return $content;
}


function curl_file_get_contents3($array, $timeout = 10)
{
    $res = array();
    if (is_string($array)) $array = array($array);
    $mh = curl_multi_init();//创建多个curl语柄
    $startime = getmicrotime();
    foreach ($array as $k => $url) {
        $conn[$k] = curl_init($url);
        curl_setopt($conn[$k], CURLOPT_TIMEOUT, $timeout);//设置超时时间
        curl_setopt($conn[$k], CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
        curl_setopt($conn[$k], CURLOPT_MAXREDIRS, 7);//HTTp定向级别
        curl_setopt($conn[$k], CURLOPT_HEADER, 0);//这里不要header，加块效率
        curl_setopt($conn[$k], CURLOPT_FOLLOWLOCATION, 1); // 302 redirect
        curl_setopt($conn[$k], CURLOPT_RETURNTRANSFER, 1);
        curl_multi_add_handle($mh, $conn[$k]);
    }

    //防止死循环耗死cpu 这段是根据网上的写法
    do {
        $mrc = curl_multi_exec($mh, $active);//当无数据，active=true
    } while ($mrc == CURLM_CALL_MULTI_PERFORM);//当正在接受数据时
    while ($active and $mrc == CURLM_OK) {//当无数据时或请求暂停时，active=true
        if (curl_multi_select($mh) != -1) {
            do {
                $mrc = curl_multi_exec($mh, $active);
            } while ($mrc == CURLM_CALL_MULTI_PERFORM);
        }
    }

    foreach ($array as $k => $url) {
        curl_error($conn[$k]);
        $res[$k] = curl_multi_getcontent($conn[$k]);//获得返回信息
        $header[$k] = curl_getinfo($conn[$k]);//返回头信息
        curl_close($conn[$k]);//关闭语柄
        curl_multi_remove_handle($mh, $conn[$k]);   //释放资源
    }

    curl_multi_close($mh);
    $endtime = getmicrotime();
    $diff_time = $endtime - $startime;
    $return = array('diff_time' => $diff_time,
        'return' => $res,
        'header' => $header
    );
    return $return['return'][0];
}


function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

function swf_replace($nr, $thisurl, &$swfstr, $host = "")
{
    $arr = array();
    $nr = preg_replace("/<div\s+class=\"cornerlayger\">(.*)<\/div>/Uisx", "", trim($nr));
    $nr = preg_replace("/<p\s+class=\"imgtitle\">(.*)<\/p>/Uisx", "", $nr);
    $nr = preg_replace("/<div\s+class=\"cornerlayger\">(.*)<\/div>/Uisx", "", $nr);
    $nr = preg_replace("/点击图片进入下一页|点击图片进下页/Uisx", "", $nr);
    if ($host == "sina.com.cn") {
        if (preg_match_all("/<\!\-\-\s*flash\s+player\s+begin\s+\-\->.*<\!\-\-\s+flash\s+player\s+end\s+\-\-\>/Uisx", $nr, $nn)) {
            $swfstr = $nn[0][0];
            return $nr;
        }
        if (preg_match_all("/<div\s+id=\"artibody\"\s+class=\"BSHARE_POP\s+blkContainerSblkCon\s+clearfix\s+blkContainerSblkCon_14\"[^<>]*>.*<\!\-\-\spublish_helper_end\s\-\->.*<\/div>/Uisx", $nr, $nn)) {
            $swfstr = $nn[0][0];
            return $nr;
        }
        if (preg_match_all("/<div[^<>]*id=\"artibody\"[^<>]*>.*<\!\-\-\spublish_helper_end\s\-\->.*<\/div>/Uisx", $nr, $nn)) {
            $swfstr = $nn[0][0];
            return $nr;
        }

        $temp = swfhost($nr, $thisurl, $swfstr, "sina.com.cn");
        if ($temp != "") $swfstr .= "[flv,500,400]" . $temp . "[/flv]\r\n";
    }


    preg_match_all("/<object(.*)<\/object>/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {

        if (preg_match("/name=\"filename\"\s+value=\"([^<>]*\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv)[^<>]*)\"/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }

        if ($mm == "" && preg_match("/value=\"[^<>\s\"\']*(http:\/\/[^<>\s\"\']*\.(flv|rm|rmvb|mov|avi|wmv|hlv))[^<>]*\"/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }

        if ($mm == "" && preg_match("/value=\"[^<>\s\"\']*(http:\/\/[^<>\s\"\']*\.(swf))[^<>]*\"/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }

        if (in_array($mm[1], $arr)) continue;
        $arr[] = $mm[1];
        preg_match("/WIDTH\:\s*([0-9]+)px/Uisx", $nn[1][$i], $mm2);
        $width = $mm2[1];
        preg_match("/height\:\s*([0-9]+)px/Uisx", $nn[1][$i], $mm2);
        $height = $mm2[1];
        if ($width == "") {
            preg_match("/width=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2);
            $width = $mm2[1];
        }
        if ($height == "") {
            preg_match("/height=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2);
            $height = $mm2[1];
        }
        $flvurl = quanurl($mm[1], $thisurl);
        if ($width < 1000 && $height > 300 && trim($flvurl) != "") {
            if (preg_match("/swf|flv/Uisx", "$mm[2]")) {
                $swfstr .= "[flash={$width},{$height}]" . $flvurl . "[/flash]\r\n";
                //$nr=str_replace($nn[0][$i],"[flash=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/flash]\r\n",$nr);
            } else {
                $swfstr .= "[media={$width},{$height}]" . $flvurl . "[/media]\r\n";
                //$nr=str_replace($nn[0][$i],"[media=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/media]\r\n",$nr);
            }
        }

    }


    if (preg_match_all("/vid=([^<>]*)(\&|\"|$|\>)/isx", $nr, $mm)) {
        $vid = $mm[1][0];
        if ($width == "") {
            preg_match("/width=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2);
            $width = $mm2[1];
        }
        if ($height == "") {
            preg_match("/height=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2);
            $height = $mm2[1];
        }

        if ($host == "ku6.com") {
            $mm[1] = "http://player.ku6.com/refer/{$vid}/v.swf";
            $mm[2] = "http://player.ku6.com/refer/{$vid}/v.swf";
        }

        //if(in_array($mm[1],$arr)) continue;
        $arr[] = $mm[1];
        if ($width <= 1000 && $height > 200) {
            if (preg_match("/swf|flv/Uisx", "$mm[2]")) {
                $swfstr .= "[flash={$width},{$height}]" . quanurl($mm[1], $thisurl) . "[/flash]\r\n";
            } else {
                $swfstr .= "[media={$width},{$height}]" . quanurl($mm[1], $thisurl) . "[/media]\r\n";
            }
        }
    }

    //echo $swfstr;
    preg_match_all("/<embed(.*)<\/embed>/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        if (preg_match("/(?:file|src)=([^<>]*\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv)[^<>]*)\"/Uisx", $nn[1][$i], $mm)) {
            $mm[1] = urldecode(preg_replace("/\"/", "", $mm[1]));
            $mm[1] = preg_replace("/autostart=false/", "autostart=true", $mm[1]);
            $mm[1] = preg_replace("/&amp;/", "&", $mm[1]);
            if (in_array($mm[1], $arr)) continue;
            $arr[] = $mm[1];
            preg_match("/WIDTH=\"?\s*([0-9]+)/isx", $nn[1][$i], $mm2);
            $width = $mm2[1];
            preg_match("/height=\"?\s*([0-9]+)/isx", $nn[1][$i], $mm2);
            $height = $mm2[1];
            if ($width <= 1000 && $height > 200) {
                if (preg_match("/swf|flv/Uisx", "$mm[2]")) {
                    $swfstr .= "[flash={$width},{$height}]" . quanurl($mm[1], $thisurl) . "[/flash]\r\n";
                    //$nr=str_replace($nn[0][$i],"[flash=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/flash]\r\n",$nr);
                } else {
                    $swfstr .= "[media={$width},{$height}]" . quanurl($mm[1], $thisurl) . "[/media]\r\n";
                    //$nr=str_replace($nn[0][$i],"[media=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/media]\r\n",$nr);
                }
            }
        }

    }

    preg_match_all("/\&lt\;object.*param\s+name=\&quot\;movie\&quot\;\s+value=\&quot\;([^<>]+)\&quot\;/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        preg_match("/WIDTH=(?:\"|\&quot\;)?\s*([0-9]+)/isx", $nn[$i][0], $mm2);
        $width = $mm2[1];
        preg_match("/height=(?:\"|\&quot\;)?\s*([0-9]+)/isx", $nn[$i][0], $mm2);
        $height = $mm2[1];
        if ($width <= 1000 && $height > 200) {
            if (preg_match("/swf|flv/Uisx", "$nn[1][$i]", $oo)) {
                $swfstr .= "[flash={$width},{$height}]" . quanurl($nn[1][$i], $thisurl) . "[/flash]\r\n";
            } else {
                $swfstr .= "[media={$width},{$height}]" . quanurl($nn[1][$i], $thisurl) . "[/media]\r\n";
            }
        }
    }

    preg_match_all("/\,videoSrc\:\s+\'(.*)\'/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        preg_match("/WIDTH=(?:\"|\&quot\;)?\s*([0-9]+)/isx", $nn[$i][0], $mm2);
        $width = $mm2[1];
        preg_match("/height=(?:\"|\&quot\;)?\s*([0-9]+)/isx", $nn[$i][0], $mm2);
        $height = $mm2[1];
        if (preg_match("/swf|flv/Uisx", "$nn[1][$i]", $oo)) {
            $swfstr .= "[flash=580,280]" . quanurl($nn[1][$i], $thisurl) . "[/flash]\r\n";
        } else {
            $swfstr .= "[media=580,280]" . quanurl($nn[1][$i], $thisurl) . "[/media]\r\n";
        }
    }

    preg_match_all("/var\s*ad\s*=\s*'([^<>]*)';\s*var\s*w\s*=\s*'([0-9]*)';\s*var\s*h\s*=\s*'([0-9]*)';/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        if (preg_match("/swf|flv/Uisx", "$nn[1][$i]", $oo)) {
            $swfstr .= "[flash={$nn[2][$i]},{$nn[3][$i]}]" . quanurl($nn[1][$i], $thisurl) . "[/flash]\r\n";
        } else {
            $swfstr .= "[media={$nn[2][$i]},{$nn[3][$i]}]" . quanurl($nn[1][$i], $thisurl) . "[/media]\r\n";
        }
    }

    preg_match_all("/<script[^<>]*>(.*)<\/script>/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        if (preg_match("/\"file\"\s*\,\s*\"([^<>]*\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))\"/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }
        if (preg_match("/file\s*\:\s*\"([^<>]*\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))\"/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }
        if (preg_match("/data\s*=\s*([^<>]*\.(swf|flv|rm|rmvb|mov|avi|wmv|hlv))/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
        }
        if (preg_match("/'src'\s*\,\s*'([^<>]*)'/Uisx", $nn[1][$i], $ss)) {
            $mm = $ss;
            $flash = 1;
        }

        if (in_array($mm[1], $arr)) continue;
        $arr[] = $mm[1];
        if (preg_match("/width\"?\s*(?:,|\:|\=)\s*\"?\s*([0-9]+)/isx", $nn[1][$i], $mm2)) $width = $mm2[1];
        if (preg_match("/height\"?\s*(?:,|\:|\=)\s*\"?\s*([0-9]+)/isx", $nn[1][$i], $mm2)) $height = $mm2[1];
        if (preg_match("/width=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2)) $width = $mm2[1];
        if (preg_match("/height=\"([0-9]+)\"/Uisx", $nn[1][$i], $mm2)) $height = $mm2[1];
        if (preg_match("/'width'\,'([0-9]+)'\,'height'\,'([0-9]+)'/Uisx", $nn[1][$i], $mm2)) {
            $width = $mm2[1];
            $height = $mm2[2];
        }
        if (preg_match("/'width'\,'([0-9]+)'\,'height'\,'([0-9]+)'/Uisx", $nn[1][$i], $mm2)) {
            $width = $mm2[1];
            $height = $mm2[2];
        }


        $flvurl = quanurl($mm[1], $thisurl);
        if ($width <= 1000 && $height > 200 && $flvurl != "" && !preg_match("/\"/", $flvurl)) {
            if (preg_match("/swf|flv/Uisx", "$mm[2]") || $flash) {
                $swfstr .= "[flash={$width},{$height}]" . $flvurl . "[/flash]\r\n";
                //$nr=str_replace($nn[0][$i],"[flash=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/flash]\r\n",$nr);
            } else {
                $swfstr .= "[media={$width},{$height}]" . $flvurl . "[/media]\r\n";
                //$nr=str_replace($nn[0][$i],"[media=x,{$width},{$height}]".quanurl($mm[1],$thisurl)."[/media]\r\n",$nr);
            }
        }
    }

    if ($vid == "" && preg_match("/\/v\/[0-9]\/[a-z]\/([^<>]+)\.html/Uisx", $thisurl, $vv)) {
        $vid = $vv[1];
        if ($host == "qq.com") {
            $nn[1][0] = "http://static.video.qq.com/TPout.swf?vid={$vid}&auto=1";
            if (preg_match("/swf|flv/Uisx", "$nn[1][$i]", $oo)) {
                $swfstr .= "[flash=580,280]" . quanurl($nn[1][0], $thisurl) . "[/flash]\r\n";
            } else {
                $swfstr .= "[media=580,280]" . quanurl($nn[1][0], $thisurl) . "[/media]\r\n";
            }
        }
    }
    if ($vid == "" && preg_match("/\?vid=([^\&<>]+)/isx", $thisurl, $vv)) {
        $vid = $vv[1];
        if ($host == "qq.com") {
            $nn[1][0] = "http://static.video.qq.com/TPout.swf?vid={$vid}&auto=1";
            if (preg_match("/swf|flv/Uisx", "$nn[1][$i]", $oo)) {
                $swfstr .= "[flash=580,280]" . quanurl($nn[1][0], $thisurl) . "[/flash]\r\n";
            } else {
                $swfstr .= "[media=580,280]" . quanurl($nn[1][0], $thisurl) . "[/media]\r\n";
            }
        }
    }
    $swfstr = preg_replace("/vid\=\&/Uisx", "vid={$vid}&", $swfstr);
    $swfstr = preg_replace("/vid=\'\s*vid\s*\'/Uisx", "vid={$vid}", $swfstr);

    return $nr;
}

function changeloadimg($textarea, $rs,$notclfdl=0)
{
    if ($rs[loadimg]&&!$notclfdl) {
        $textarea = preg_replace("/\[img\](?!http\:\/\/collect\.longsunhd\.com)(.*)\[\/img\]/Uisxe", '"[img]http://collect.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url=".surlencode("\\1")."[/img]"', $textarea);
    }
    return $textarea;
}

function curl3($post, $cookie = "")
{
    $POSTFIELDS = "";

    if (substr($post, 0, 7) == "http://") {
        $post = urltopoststr2($post, $cookie);
    }

    preg_match_all("/^Host\:(\s*.*)$/Uimx", $post, $nn);
    $host = trim(chop($nn[1][0]));
    $site = "http://" . $host;
    preg_match_all("/^(POST|GET)\s+(.*)\s+HTTP/Umx", $post, $uu);
    $url = preg_replace("/\/+$/", "", $site) . "/" . preg_replace("/^\/+/", "", chop($uu[2][0]));
    preg_match_all("/^Referer\:(\s*.*)$/Uimx", $post, $nn);
    $Referer = trim(chop($nn[1][0]));
    preg_match_all("/(?:\r\n\r\n|\n\n)(.*)$/Uis", $post, $nn);
    $Querystring = trim(chop($nn[1][0]));
    preg_match_all("/boundary=(.*)$/Uim", $post, $nn);
    $boundary = trim(chop($nn[1][0]));
    $filename = $url;
    //$filename=$url.(preg_match("/\?/",$url)?"&":"?").$Querystring;
    //$filename=preg_replace("/http\:\/\/[^\/]*\//Uisx","/",$filename);
    $user_agent = "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)";
    $POSTFIELDS = $Querystring;

    $ch = curl_init();


    $timeout = 60;
    curl_setopt($ch, CURLOPT_URL, $filename);
    //curl_setopt ($ch, CURLOPT_MUTE, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
    curl_setopt($ch, CURLOPT_HEADER, 1);//要求输出头信息
    if ($uu[1][0] == "POST") curl_setopt($ch, CURLOPT_POST, 1);
    if (preg_match("/multipart/Uisx", $post)) {
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data; boundary=$boundary"));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    }
    if ($Referer != "") curl_setopt($ch, CURLOPT_REFERER, $Referer);
    if ($cookie != "") curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    if ($Querystring != "" && $uu[1][0] == "POST") {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $Querystring);
    }
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $result = curl_exec($ch);
    curl_close($ch);

    preg_match("/(^.*)(?:\r\n\r\n|\n\n)(.*?)$/Uis", $result, $nn);
    $header = $nn[1];
    $body = $nn[2];

    if (@gzinflate(substr($body, 10))) {
        $body = @gzinflate(substr($body, 10));
    }


    //---------------解chunk编码

    if (strpos($result, 'chunk')) {
        $tmpfile = tempnam('/tmp', 'webcache');
        $fp = fopen($tmpfile, 'w');
        fwrite($fp, $result);
        fclose($fp);
        ob_start();
        readgzfile($tmpfile);
        $result = ob_get_contents();
        ob_end_clean();
        unlink($tmpfile);
    }

    $result = $header . "\r\n\r\n" . $body;
    $nr = $result;
    //$nr=preg_replace("/<(\/?script[^>]*)>/Uisx","<!--\\1-->",$nr);
    return $nr;
}

function chunk($result)
{
    if (@gzinflate(substr($result, 10))) {
        $result = @gzinflate(substr($result, 10));
    }
    if (strpos($result, 'chunk')) {
        $tmpfile = tempnam('/tmp', 'webcache');
        $fp = fopen($tmpfile, 'w');
        fwrite($fp, $result);
        fclose($fp);
        ob_start();
        readgzfile($tmpfile);
        $result = ob_get_contents();
        ob_end_clean();
        unlink($tmpfile);
    }
    return $result;
}

function curl4($post, $cookie = "")
{
    $POSTFIELDS = "";

    preg_match_all("/^Host\:(\s*.*)$/Uimx", $post, $nn);
    $host = trim(chop($nn[1][0]));
    $site = "http://" . $host;
    preg_match_all("/^(POST|GET)\s+(.*)\s+HTTP/Umx", $post, $uu);
    $url = preg_replace("/\/+$/", "", $site) . "/" . preg_replace("/^\/+/", "", chop($uu[2][0]));
    preg_match_all("/^Referer\:(\s*.*)$/Uimx", $post, $nn);
    $Referer = trim(chop($nn[1][0]));
    preg_match_all("/\r\n\r\n(.*)$/Uis", $post, $nn);
    $Querystring = trim(chop($nn[1][0]));
    preg_match_all("/boundary=(.*)$/Uim", $post, $nn);
    $boundary = trim(chop($nn[1][0]));
    $filename = $url;
    //$filename=$url.(preg_match("/\?/",$url)?"&":"?").$Querystring;
    $user_agent = "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)";
    $POSTFIELDS = $Querystring;

    $ch = curl_init();

    $timeout = 60;
    curl_setopt($ch, CURLOPT_URL, $filename);
    //curl_setopt ($ch, CURLOPT_MUTE, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/99.99 (compatible; MSIE 99.99; Windows XP 99.99)");
    curl_setopt($ch, CURLOPT_HEADER, 0);//要求输出头信息
    if ($uu[1][0] == "POST") curl_setopt($ch, CURLOPT_POST, 1);
    if (preg_match("/multipart/Uisx", $post)) {
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data; boundary=$boundary"));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    }
    if ($Referer != "") curl_setopt($ch, CURLOPT_REFERER, $Referer);
    if ($cookie != "") curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    if ($Querystring != "" && $uu[1][0] == "POST") {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $Querystring);
    }

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

    $result = @curl_exec($ch);
    curl_close($ch);

    preg_match_all("/(^.*)\r\n\r\n(.*?)$/Uis", $result, $nn);
    $header = $nn[1];
    $body = $nn[2];
    if (@gzinflate(substr($body, 10))) {
        $result = @gzinflate(substr($nn[2][0], 10));
    }
    //$result=$body;
    $nr = $result;
    //$cookie=getcookie($result);
    //setcookieto();
    //$nr=preg_replace("/<(\/?script[^>]*)>/Uisx","<!--\\1-->",$nr);
    return $nr;
}


if (!function_exists('urltopoststr2')) {
    function urltopoststr2($post, $cookies)
    {
        $publicpoststr = <<<TEXT
GET {surl} HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/QVOD, application/QVOD, * / *
Accept-Language: zh-CN
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Foxy/1; QQDownload 702; GTB7.2; Foxy/1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C)
Accept-Encoding: gzip, deflate
cookies:{cookies}
Proxy-Connection: Keep-Alive
Host: {host}


TEXT;
        preg_match_all("/(http\:\/\/([^\/]*?))(.*)$/Uimx", $post, $mm);
        $host = $mm[2][0];
        $surl = $mm[3][0];
        $publicpoststr = str_replace("{host}", $host, $publicpoststr);
        $publicpoststr = str_replace("{surl}", $surl, $publicpoststr);
        $publicpoststr = str_replace("{cookies}", $cookies, $publicpoststr);
        return trim($publicpoststr) . "\r\n\r\n";
    }
}

function evalpublic(&$textarea, $thisurl, $params = array(), $rs, $bug = 0)
{
    global $news2, $nn11, $nn221, $nn99;
    extract($params);
    $returntextarea = $textarea;
    if (count($nn221[1]) > 0) {
        $returntextarea = "";
        $nn22 = $nn221;
    }
    if (count($nn22[1]) > 0) {
        for ($i = 0; $i < count($nn22[1]); $i++) {
            if (preg_match("/http|\.[a-zA-Z0-9]+/Uisx", $nn22[1][$i], $nn)) {
                $url = $nn22[1][$i];
                $title = $nn22[2][$i];
            } else {
                $url = $nn22[2][$i];
                $title = $nn22[1][$i];
            }
            $url = preg_replace("/_small\.jpg/Uisx", ".jpg", trim($url));
            $url = preg_replace("/thumb_[0-9]+_[0-9]+_/Uisx", "", trim($url));
            if (trim($url) != "") $returntextarea .= createimgubb($url, $title, $rs[loadimg], $thisurl);

        }
    }

    if (count($nn11[1]) > 0) {
        $nr = $nn11[1][0];
        for ($i = 0; $i < count($nn11[1]); $i++) {
            $nr = preg_replace("/_small\.jpg/Uisx", ".jpg", $nr);
            $nr = preg_replace("/thumb_[0-9]+_[0-9]+_/Uisx", "", $nr);
            if (trim($nr) != "") $returntextarea = $nr . "\r\n" . $returntextarea;
        }
    }

    if (count($nn99[1]) > 0) {
        //echo quanurl($nn99[1][0],$thisurl)."\r\n";
        $nr = redo(quanurl($nn99[1][0], $thisurl), $news2->secexe);
        if (trim($nr) != "") $returntextarea .= $nr;
    }

    $textarea = $returntextarea;
    return $returntextarea;
}

function createimgubb($url, $title, $loadimg, $thisurl)
{
    $textarea = "";
    $title2 = unicode_decode1($title);
    if ($loadimg) {
        $url = str_replace("%", "BAIFENHAO", $url);
        $textarea .= "\r\n[img]http://collect.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url=" . surlencode(quanurl(trim($url), $thisurl)) . "[/img]\r\n\r\n{$title2}\r\n";
    } else {
        $textarea .= "\r\n[img]" . quanurl(trim($url), $thisurl) . "[/img]\r\n{$title2}\r\n";
    }
    return $textarea;
}

function dore($re, $tempnr = "", $ytempnr = "", $thisurl = "", $rs = array())
{
    global $news, $bug, $nn22, $nn221, $nn11;
    $textarea = "";
    $cc = preg_split("/\|\|\||$/m", $re);
    for ($i = 0; $i < count($cc); $i++) {
        if (trim($cc[$i]) == "") continue;
        if (!preg_match("/\&\&\&/Uisx", $cc[$i])) {
            if (preg_match("/\:y(?=$|\:)/Uisx", trim($cc[$i]))) {
                $cc[$i] = preg_replace("/\:y(?=$|\:)/", "", $cc[$i]);
                $tempnr = $ytempnr;
            }
            if (preg_match("/\:nn([0-9]+)(?=$|\:)/Uisx", trim($cc[$i]), $mm4)) {
                $cc[$i] = preg_replace("/\:nn[0-9]+(?=$|\:)/Uisx", "", trim($cc[$i]));
                $cc[$i] = (!isutf8($cc[$i])) ? u(trim($cc[$i])) : trim($cc[$i]);
                preg_match_all("/" . trim($cc[$i]) . "/Uisx", $tempnr, ${"nn" . $mm4[1]});
            } else {
                if (trim($textarea) == "") {
                    $cc[$i] = (!isutf8($cc[$i])) ? u(trim($cc[$i])) : trim($cc[$i]);
                    preg_match_all("/" . trim($cc[$i]) . "/Uisx", $tempnr, $nn);
                    $textarea = trim($nn[1][0]);
                }
            }
        } else {
            $ddd = explode("&&&", $cc[$i]);
            $tempnr2 = $tempnr;
            if (count($ddd) > 1) {
                for ($d = 0; $d < count($ddd) - 1; $d++) {
                    preg_match_all("/" . trim($ddd[$d]) . "/Uisx", $tempnr2, $nn);
                    $tempnr2 = $nn[1][0];
                    //echo trim($ddd[$d]).$tempnr2;
                }


                if (preg_match("/\:nn([0-9]+)(?=\:|$)/Uisx", trim($ddd[count($ddd) - 1]), $mm4)) {
                    $ddd[count($ddd) - 1] = preg_replace("/\:nn[0-9]+(?=\:|$)/Uisx", "", trim($ddd[count($ddd) - 1]));
                    preg_match_all("/" . trim($ddd[count($ddd) - 1]) . "/Uisx", $tempnr, ${"nn" . $mm4[1]});
                }
            }
        }

    }

    $oo = ${"nn" . $mm4[1]};

    if (count($oo) > 0) {
        $params = array("nn22" => $nn22, "nn221" => $nn221, "nn11" => $nn11);
        $textarea .= evalpublic($textarea, $thisurl, $params, $rs, $bug);
    }
    return $textarea;
}

function surlencode($url)
{
    if (preg_match("/http%3A%2F%2F/Uisx", $url)) {
        return $url;
    }
    $url = urlencode(str_replace("%", "BAIFENHAO", $url));
    return $url;
}

function replacedxkh($nr)
{
    $nr = str_replace("<", "&lt;", $nr);
    $nr = str_replace(">", "&gt;", $nr);
    return $nr;
}

function loopbz($nr, $divre = "<div[^<>]*class=\"spaceborder\"[^<>]*>", $firstre = "<img[^<>]*src=\"([^<>]*(uface|userface)[^<>]*)\"[^<>]*>", $contentre = "<div\s+class=\"bshare\-image2share\"[^<>]*>(.*)<span")
{
    global $first;
    $textarea = "";
    preg_match_all("/($divre)(.*)(?=$divre)/Uisx", $nr, $nn);
    for ($i = 0; $i < count($nn[1]); $i++) {
        if (preg_match("/$firstre/Uisx", $nn[0][$i], $mm) && $first == "") {
            //echo 4;
            $first = $mm[0];
            if ($contentre != "") {
                preg_match("/$contentre/Uisx", $nn[0][$i], $mm2);
                $textarea .= $mm2[1];
            } else {
                $textarea .= $nn[0][$i];
            }
        } elseif ($first != "" && preg_match("/" . addsla($first) . "/Uisx", $nn[0][$i])) {
            echo 5;
            if ($contentre != "") {
                preg_match("/$contentre/Uisx", $nn[0][$i], $mm2);
                $textarea .= $mm2[1];
            } else {
                $textarea .= $nn[0][$i];
            }
        }

    }
    return $textarea;
}


function utf8_unicode($c)
{
    switch (strlen($c)) {
        case 1:
            return ord($c);
        case 2:
            $n = (ord($c[0]) & 0x3f) << 6;
            $n += ord($c[1]) & 0x3f;
            return $n;
        case 3:
            $n = (ord($c[0]) & 0x1f) << 12;
            $n += (ord($c[1]) & 0x3f) << 6;
            $n += ord($c[2]) & 0x3f;
            return $n;
        case 4:
            $n = (ord($c[0]) & 0x0f) << 18;
            $n += (ord($c[1]) & 0x3f) << 12;
            $n += (ord($c[2]) & 0x3f) << 6;
            $n += ord($c[3]) & 0x3f;
            return $n;
    }
}

function utf8_unicode2($str)
{
    $temp = "";
    preg_match_all("/[\x80-\xff]?./", $str, $ar);
    foreach ($ar[0] as $v)
        //$temp.="&#".utf8_unicode($v).";";
        //$temp.="&amp;#".utf8_unicode(iconv("GB2312","UTF-8",$v)).";";
        $temp .= "&#" . utf8_unicode($v) . ";";
    return $temp;
}


function jsstart($name = 'default')
{
    global $ss_timing_start_times;
    $ss_timing_start_times[$name] = explode(" ", microtime());
}

function jsstop($name = 'default')
{
    global $ss_timing_stop_times;
    $ss_timing_stop_times[$name] = explode(" ", microtime());
}

function js($name = 'default')
{
    global $ss_timing_start_times, $ss_timing_stop_times;
    if (!isset($ss_timing_start_times[$name])) {
        return 0;
    }
    if (!isset($ss_timing_stop_times[$name])) {
        $stop_time = explode(" ", microtime());
    } else {
        $stop_time = $ss_timing_stop_times[$name];
    }
    $current = $stop_time[1] - $ss_timing_start_times[$name][1];
    $current += $stop_time[0] - $ss_timing_start_times[$name][0];
    return $current;
}


function swfhost($nr, $thisurl, &$swfstr, $host)
{
    switch ($host) {
        case "sina.com.cn":
            if (preg_match("/vid\s*=\"([0-9]+)\"/isx", $nr, $nn)) {
                $vid = $nn[1];
            }
            if (preg_match("/vid\s*\:\'([0-9]+)\'\,/Uisx", $nr, $nn)) {
                $vid = $nn[1];
            }
            if (preg_match("/uid\s*\:\'([0-9]+)\'\,/Uisx", $nr, $nn)) {
                $uid = $nn[1];
            }
            if (preg_match("/sid\s*\:\'([0-9]+)\'\,/Uisx", $nr, $nn)) {
                $sid = $nn[1];
            }
            if (preg_match("/tid\s*\:\'([0-9]+)\'\,/Uisx", $nr, $nn)) {
                $tid = $nn[1];
            }
            if (preg_match("/pid\s*\:\'([0-9]+)\'\,/Uisx", $nr, $nn)) {
                $pid = $nn[1];
            }
            $uid = ($uid == "") ? 6 : $uid;
            $tid = ($tid == "") ? 2 : $tid;
            $pid = ($pid == "") ? 1 : $pid;
//echo "http://v.iask.com/v_play.php?vid={$vid}&uid={$uid}&pid={$pid}&tid={$tid}&referrer=&ran=0.2793316".rand(1000,9999)."28716&r=video.sina.com.cn";
            $nr = curl_file_get_contents("http://v.iask.com/v_play.php?vid={$vid}&uid={$uid}&pid={$pid}&tid={$tid}&referrer=&ran=0.2793316" . rand(1000, 9999) . "28716&r=video.sina.com.cn");
            if (preg_match("/<url><\!\[CDATA\[(.*)\]\]><\/url>/Uisx", $nr, $nn)) {
                $url = $nn[1];
            }
            return $url;
            break;
    }
}

function unicode_decode($name)
{
    $name = trim($name);
    $name = preg_replace("/[\\\\\\|\/]?u([0-9a-zA-Z]{4})/ie", 'zh2("\\1")', $name); //%u\\1
    $name = preg_replace("/(\\\u([0-9a-z]{1,4}))/ie", 'zh("\\1")', $name);
    $name = unicode_decode2($name);
    return $name;
}

function unicode_decode_utf8($name)
{
    $name = unicode_decode(trim($name));
    $name = mb_convert_encoding($name, "gb2312", "UTF-8");
    return $name;
}


function unicode_decode0($name)
{
    $name = trim($name);
    $name = preg_replace("/[\\\\\\|\/]?u([0-9a-zA-Z]{4})/ie", 'zh2("\\1")', $name); //%u\\1
    return $name;
}

function unicode_decode1($name)
{
    $name = trim($name);
    $name = preg_replace("/[\\\\\\|\/]?u([0-9a-zA-Z]{4})/ie", 'zh2("\\1")', $name); //%u\\1
    $name = preg_replace("/(\\\u([0-9a-z]{1,4}))/ie", 'zh("\\1")', $name);
    $name = unicode_decode2($name);
    return $name;
}

function zh($str)
{
    $code = base_convert(substr($str, 2, 2), 16, 10);
    $code2 = base_convert(substr($str, 4), 16, 10);
    $c = chr($code) . chr($code2);
    $c = iconv('UCS-2', 'GB2312//IGNORE', $c);
    return $c;
}

function zh2($str)
{
    $c = "&#x" . $str;
    return $c;
}


function unicode_decode2($str)
{
    $str = rawurldecode($str);
    preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U", $str, $r);
    $ar = $r[0];
    foreach ($ar as $k => $v) {
        if (substr($v, 0, 2) == "%u") {
            $ar[$k] = iconv("UCS-2", "GB2312", pack("H4", substr($v, -4)));
        } elseif (substr($v, 0, 3) == "&#x") {
            $ar[$k] = iconv("UCS-2", "GB2312", pack("H4", substr($v, 3, -1)));
        } elseif (substr($v, 0, 2) == "&#") {
            $ar[$k] = iconv("UCS-2", "GB2312", pack("n", substr($v, 2, -1)));
        }
    }
    return join("", $ar);
}

function r($nr)
{
    $fn = fopen("D:/TMPTMP_ytempnr.txt", "w");
    fwrite($fn, $nr);
    fclose($fn);
    $fn = fopen("D:/1.txt", "w");
    fwrite($fn, $nr);
    fclose($fn);
}

//echo jcre('<div id="header">...<div class="content">...<div class="logo">')
